package net.bwie.realtime.jtp.dws.log.utils;

import org.wltea.analyzer.core.IKSegmenter;
import org.wltea.analyzer.core.Lexeme;

import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;

public class AnalyzerUtil {
    public static List<String> ikAnalyzer(String content) throws Exception{
        ArrayList<String> list = new ArrayList<>();
        IKSegmenter ikSegmenter = new IKSegmenter(new StringReader(content), true);
        Lexeme lexeme;
        while ((lexeme = ikSegmenter.next()) != null) {
            list.add(lexeme.getLexemeText());
        }

        return list;
    }

    public static void main(String[] args) {
        try {
            List<String> list = ikAnalyzer("hello world");
            System.out.println(list);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
